<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="/context/mytags.jsp"%>
<t:base type="jquery,easyui,tools,DatePicker"></t:base>
<div class="easyui-layout" fit="true">
  <div region="center" style="padding:0px;border:0px">
  <t:datagrid name="deviceList" checkbox="false" fitColumns="true" title="加工服务申请列表" actionUrl="processingServiceController.do?myApplyDatagrid" idField="id" fit="true" queryMode="group">
   <t:dgCol title="主键"  field="id"  hidden="true"  queryMode="single"  width="1"></t:dgCol>
   <t:dgCol title="创建日期"  field="createDate" formatter="yyyy-MM-dd" hidden="true"  queryMode="single"  width="1"></t:dgCol>
   <t:dgCol title="state"  field="state.value"  hidden="true"  queryMode="single"  width="1"></t:dgCol>   
   <t:dgCol title="申请人" field="applyUser.realName" width="60" ></t:dgCol>
   <t:dgCol title="手机号" field="applyCellphone" width="90" ></t:dgCol> 
   <t:dgCol title="加工名称"  field="title"   query="true" queryMode="single"  width="100"></t:dgCol>
   <t:dgCol title="状态"  field="state.name"  hidden="false"  queryMode="single"  width="60"></t:dgCol>
   <t:dgCol title="分配教师"  field="assignTeacher.realName"   query="true" queryMode="single"  width="60"></t:dgCol>
   <t:dgCol title="审核意见"  field="auditContent"  hidden="false"  queryMode="single"  width="100"></t:dgCol>
   <t:dgCol title="加工时长"  field="processingDuration"   queryMode="single"  width="50"></t:dgCol>
   <t:dgCol title="毛坯价格"  field="totalAmount"   queryMode="single"  width="50"></t:dgCol>
   <t:dgCol title="评价分数"  field="serviceScore"   queryMode="single"  width="50"></t:dgCol>
   <t:dgCol title="操作" field="opt" width="140"></t:dgCol>
   
   <t:dgFunOpt  funname="submit(id)" title="提交申请" exp="state.value#eq#0"/>
   <t:dgFunOpt  funname="viewDetail(id)" title="查看进度" exp="state.value#eq#4,5"/>
   <t:dgFunOpt  funname="doScore(id)" title="评价打分" exp="state.value#eq#6"/>        
   <t:dgFunOpt  funname="downloadAtta(id)" title="下载图纸" />
   <t:dgFunOpt  funname="editItemDetail({'编辑'},{'processingServiceController.do?goUpdate'},id,{'700'},{'400'})" title="编辑" exp="state.value#eq#0" />
   <t:dgFunOpt  funname="showItemDetail({'查看'},{'processingServiceController.do?goUpdate'},id,{'700'},{'400'})" title="查看"  />
   <t:dgFunOpt  funname="doDelete(id)" title="删除" exp="state.value#eq#0"/>
   <t:dgToolBar title="录入" icon="icon-add" url="processingServiceController.do?goAdd" funname="add" height="400" width="700"></t:dgToolBar>
  </t:datagrid>
  </div>
 </div>
 <script type="text/javascript">


 function doDelete(id){
	 $.dialog.confirm('确定要删除吗?', function(r) {
		if (r) {
		   $.ajax({
			   url:"processingServiceController.do?doDel&id="+id,
			   success:function (data){
					data = $.parseJSON(data);
					if(data.success){
						tip("操作成功");
						reloadTable();
					}else{
						tip("操作失败！");
					}
				}		   
		   });
		}
	});
 }
 
function submit(id){
	$.dialog.confirm('确定要提交吗?', function(r) {
		   if (r) {
			   doSubmit(id);
			}
	});
}

function doSubmit(id){
	$.ajax({
		url:"processingServiceController.do?submit&id="+id,
		success:function (data){
			data = $.parseJSON(data);
			if(data.success){
				tip("操作成功");
				reloadTable();
			}else{
				tip("操作失败！");
			}
		}
	});
}
 
 //评价打分
 function doScore(id){
	 var addurl = 'processingServiceController.do?goScore&id='+id;
	  $.dialog({
		  	id:'deviceReturn',
			content: 'url:'+addurl,
			lock : true,
			zIndex: 50, 
			width:400,
			height:100,
			title:'评价打分', 
			opacity : 0.3,
			ok: function(){
				iframe = this.iframe.contentWindow;
				$('#btn_sub', iframe.document).click(); 
				return false;
			},
			cache:false,
			close:reloadTable
	});	 
 }
 
 //查看加工明细
 function viewDetail(id){
	 var addurl = 'processingServiceController.do?showProcessingInfo&id='+id;
	  $.dialog({
		  	id:'deviceReturn',
			content: 'url:'+addurl,
			lock : true,
			zIndex: 50, 
			width:500,
			height:400,
			title:'查看加工进度', 
			opacity : 0.3,
			ok:false,
			cache:false,
			close:true
	});	 
 }
 

function downloadAtta(id){
	window.location.href="cms-attach.do?download&ownerId="+id;
}
 </script>